//package com.ebai.product.management.base.security;
//
//import com.ebai.product.management.model.entity.User;
//import org.apache.log4j.Logger;
//import org.aspectj.lang.ProceedingJoinPoint;
//import org.aspectj.lang.annotation.*;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Component;
//import org.springframework.ui.Model;
//import org.springframework.web.context.request.RequestContextHolder;
//import org.springframework.web.context.request.ServletRequestAttributes;
//
//import javax.servlet.ServletException;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import javax.servlet.http.HttpSession;
//import java.io.IOException;
//import java.io.PrintWriter;
//
//@Aspect
//@Component
//public class UserTokenInterceptor {
//
//    private Logger logger = Logger.getLogger(this.getClass());
//
//    @Autowired
//    private BasicSecurityManager basicSecurityManager;
//
//    @Pointcut("execution(public * com.ebai.product.*.controller..*.*Page(..))")
//    public void checkToken() {
//
//    }
//
//    @Before(value="checkToken()")
//    public void beforeCheckToken()throws ServletException, IOException{
//        logger.debug("前置通知，在方法执行之前执行：检查用户登录状态！");
//
//        ServletRequestAttributes requestAttributes = (ServletRequestAttributes)RequestContextHolder.getRequestAttributes();
//        HttpServletRequest request = requestAttributes.getRequest();
//        HttpServletResponse response = requestAttributes.getResponse();
//        HttpSession session = request.getSession();
//
//        User user = this.basicSecurityManager.getCurrentUser(session);
//        if (null == user) {
////            StringBuffer sbUrl = new StringBuffer();
////            sbUrl.append("http://")
////                    .append(request.getServerName())
////                    .append(":")
////                    .append(request.getServerPort())
////                    .append(request.getContextPath())
////                    .append("/login.html");
////            logger.debug(sbUrl.toString());
////            response.sendRedirect(sbUrl.toString());
//
//            PrintWriter out = response.getWriter();
//            out.println("<html>");
//            out.println("<head>");
//            out.println("<meta http-equiv='Expires' CONTENT='0'>");
//            out.println("<meta http-equiv='Cache-Control' CONTENT='no-cache'>");
//            out.println("<meta http-equiv='Pragma' CONTENT='no-cache'>");
//            out.println("<script>");
//            out.println("top.location = 'login.html';");
//            out.println("</script>");
//            out.println("</head>");
//            out.println("</html>");
//        }
//    }
//}
